package com.wish.wishhouse_resource.service.impl;

import com.wish.wishhouse_resource.entity.TbBusiness;
import com.wish.wishhouse_resource.mapper.TbBusinessMapper;
import com.wish.wishhouse_resource.service.ITbBusinessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wish.wishhouse_resource.entity.BusinessStatus;
import com.wish.wishhouse_resource.entity.BusinessType;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 商户表 服务实现类
 * </p>
 *
 * @author wsx
 * @since 2021-04-02
 */
@Service
public class TbBusinessServiceImpl extends ServiceImpl<TbBusinessMapper, TbBusiness> implements ITbBusinessService {
    @Resource
    private TbBusinessMapper tbBusinessMapper;
    @Override
    public TbBusiness queryObject(Integer id) {
        TbBusiness tbBusiness = tbBusinessMapper.queryObject(id);
        tbBusiness.setStatusName(BusinessStatus.getName(tbBusiness.getStatus()));
        tbBusiness.setTypeName(BusinessType.getName(tbBusiness.getType()));
        Date createTime = tbBusiness.getCreateTime();
        DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(createTime);
        tbBusiness.setCreateTimes(format);
        return tbBusiness;
    }
}
